//
//  YXLookOriginalImageViewController.m
//  YXImageBrowserDemo
//
//  Created by guo peng huang on 2021/5/19.
//

#import "YXLookOriginalImageViewController.h"
#import "YXBaseFileManager.h"
#import "YXImageData.h"
#import "YXLookOriginalImageToolViewHandler.h"
#import "YXImageBrowser.h"

@interface YXLookOriginalImageViewController ()

@end

@implementation YXLookOriginalImageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)initData {
    self.dataArray = [YXBaseFileManager yx_imageURLs];
}

+ (NSString *)yx_title {
    return @"自定义工具视图(例查看原图";
}

- (void)yx_selectedIndex:(NSInteger)index {
    NSMutableArray *datas = [NSMutableArray array];
    [self.dataArray enumerateObjectsUsingBlock:^(NSString *_Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        YXImageData *data = [YXImageData new];
        data.imageURL = [NSURL URLWithString:obj];
        data.projectiveView = [self viewAtIndex:idx];
        // 这里放的是原图地址（实际业务中请按需关联）
        data.extraData = [NSURL URLWithString:@"https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=3752091891,3333222095&fm=26&gp=0.jpg"];
        [datas addObject:data];
        
    }];
    
    YXImageBrowser *browser = [YXImageBrowser new];
    // 自定义工具栏
    browser.toolViewHandlers = @[YXLookOriginalImageToolViewHandler.new];
    browser.dataSourceArray = datas;
    browser.currentPage = index;
    [browser show];
}

@end
